//导入joi
const Joi = require("joi");

//定义文章id验证
const id = Joi.number().min(1).required()
const name = Joi.string().required().messages({
    'string.empty': "类别名称不能为空"
})
const alias = Joi.string().required().error(errors => {
    for (err of errors) {
        switch (err.code) {
            case 'string.empty':
                return new Error("类别别名不能为空")
        }
    }
})

exports.artcate_add_schema = {
    body: {
        name,
        alias
    }
}
exports.artcate_update_schema = {
    body: {
        id,
        name,
        alias
    }
}

exports.artcate_delete_schema = {
    params: {
        id
    }
}

exports.artcate_get_schema = {
    params: {
        id
    }
}
